package com.ocom.mqsimple.controller;

import com.ocom.common.constant.MqSimpleApiUrl;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.RandomUtil;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.webapi.ExcelAddPersonVo;
import com.ocom.mqsimple.business.person.ImportPerSonProductService;
import com.ocom.redis.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description: 人脸失败
 * @Author: 朱晖
 * @Date: 2022/9/1
 **/
@Slf4j
@RestController
public class ImportPersonController {

	@Autowired
	ImportPerSonProductService importPerSonProductService;

	@Resource
	RedisUtil redisUtil;

	@PostMapping(MqSimpleApiUrl.URL_importPerson)
	public Result ImportPerson(@RequestBody ExcelAddPersonVo request){

		String mqKey = "MqSimple:ImportPerson:"+ System.currentTimeMillis()+RandomUtil.getRandomString(20);
		redisUtil.set(mqKey,request,7300l);
		log.info("导入人员开始,【{}】",request);
		importPerSonProductService.handle(mqKey);
		return ResultUtil.success();

	}

}
